public class test {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        sortEvenOdd(arr);

        // 打印结果
        for (int num : arr) {
            System.out.print(num + " ");
        }
    }

    public static void sortEvenOdd(int[] arr) {
        int left = 0;
        int right = arr.length - 1;

        while (left < right) {
            // 找到右边的奇数
            while (left < right && arr[right] % 2 == 0) {
                right--;
            }
            // 找到左边的偶数
            while (left < right && arr[left] % 2 != 0) {
                left++;
            }
            // 交换奇数和偶数
            if (left < right) {
                int temp = arr[left];
                arr[left] = arr[right];
                arr[right] = temp;
            }
        }
    }
}